import { ToggleType } from './../reducer/todo';
import { TODO_ADD, TODO_ALLCHECKED } from './actionType';

import { ActionType } from '../reducer/todo';

const todoDelByIdAction = (id: number): ActionType => ({
  type: 'todo/delbyid',
  payload: id,
});

const todoClearIsDoneAction = (): ActionType => ({ type: 'todo/clearIsDone' });

const todoSingleAction = (payload: number): ActionType => ({
  type: 'todo/singlechecked',
  payload,
});

const todoAddAction = (payload: string): ActionType => ({
  type: TODO_ADD,
  payload,
});

const todoAllCheckedAction = (payload: boolean): ActionType => ({
  type: TODO_ALLCHECKED,
  payload,
});

const todoSetTypeAction = (type: ToggleType): ActionType => ({
  type: 'todo/settype',
  payload: type,
});

export {
  todoAddAction,
  todoSingleAction,
  todoAllCheckedAction,
  todoDelByIdAction,
  todoSetTypeAction,
  todoClearIsDoneAction,
};
